<template>
	<view class="yt-card-time" @click="to">
		<view class="time">
			{{format_time}}
		</view>
		<view class="yt-card-time_box">
			<view class="yt-card-time-head">
				{{head}}
			</view>
			<slot></slot>
		</view>
	</view>
</template>

<script>
	export default{
		props:['time','head'],
		data(){
			return {
				format_time:this.Format(new Date(this.time)) 
			}
		},
		methods:{
			to(){
				this.$emit('click')
			},
			Format(fmt){
				let y = ''
				let m = ''
				let d = ''
				let h = ''
				let min = ''
				let s = ''
				d = fmt.getDate()
				d = d < 10 ? '0' + d : d
				m = fmt.getMonth() + 1
				m = m < 10 ? '0' + m : m
				y = fmt.getFullYear()
				h = fmt.getHours() // 小时
				h = h < 10 ? '0' + h : h
				min = fmt.getMinutes() // 分
				min = min < 10 ? '0' + min : min
				s = fmt.getSeconds() // 秒
				s = s < 10 ? '0' + s : s
				return `${y}-${m}-${d}  ${h}:${min}:${s}`; 
			}
		}
	}
</script>

<style>
	.time{
		width: 50%;
		display: block;
		margin: 23.8rpx auto;
		background-color: #fff;
		text-align: center;
		border-radius: 23.8rpx;
		font-size: 32.04rpx;
		color: #636363FF;
		padding: 0 20rpx;
	}
	.yt-card-time_box{
		width: 90%;
		background-color: #fff;
		margin: 23.8rpx auto;
		border-radius: 45.39rpx;
		padding: 23.8rpx 42.85rpx 23.8rpx 42.85rpx;
	}
	.yt-card-time-head{
		font-size: 42.72rpx;
	}
</style>
